//
//  ActStatusRequest.m
//  BaseProject
//
//  Created by 王洋 on 2021/4/23.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "ActStatusRequest.h"

@implementation ActStatusRequest

+ (void)request_ActStatusComption:(void (^)(BOOL success, ActStatusModel *model))comption {

    NSMutableDictionary *dic = @{}.mutableCopy;
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_GetActive];

    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                NSArray *statusArray = [data valueForKey:@"data"];
                
                if ([statusArray isKindOfClass:[NSArray class]]) {
                    
                    for (NSDictionary *dic in statusArray) {
                        ActStatusModel *model = [ActStatusModel modelWithDictionary:dic];
                        if ([model.activeType isEqualToString:@"2"]) {
                            comption(YES, model);
                        }
                    }
                }
            } else {
                comption(NO, [ActStatusModel new]);
            }
        } else {
            comption(NO, [ActStatusModel new]);
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        comption(NO, [ActStatusModel new]);
    }];

}

@end
